package com.chinaway.dsp.util;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.BrowserFunction;

import com.chinaway.dsp.action.BackAction;
import com.chinaway.dsp.util.CoordinateConversion;
import com.chinaway.dsp.util.Point;

public class CallHtml extends BrowserFunction{
	List<Point> lnglat = new ArrayList<Point>();
	Browser browser;
	BackAction ba;
	public CallHtml(Browser browser, String name,BackAction backAction) {
		super(browser, name);
		this.browser=browser;
		this.ba=backAction;
	}
	
	@Override  
    public Object function(Object[] arg0) {
		CoordinateConversion cc=new CoordinateConversion();
		Double count = ((Double)arg0[1]);
		int tracecount=count.intValue();
	    System.out.println(tracecount);
	    String location = ((String)arg0[0]);
	    String[] location_trace=location.split("A");
	    for(int i=0;i<location_trace.length;i++){
	    	System.out.println(location_trace[i]);
	    	String[] latlng=location_trace[i].split(",");
	    	Point wgs84=cc.gcj_To_Gps84(Double.parseDouble(latlng[1]), Double.parseDouble(latlng[0]));
	    	lnglat.add(wgs84);
	    }
	    System.out.println("wgs84 size:"+lnglat.size());
	    /*for(int i=0;i<lnglat.size();i++){
	    	System.out.println(String.format("%.6f", lnglat.get(i).getWgLat())+","+""+String.format("%.6f", lnglat.get(i).getWgLon()));
	    }*/
	    
        return "路线已选择";
    }
	
	public List getRouteList(){
		return lnglat;
	}
}
